home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / PIECES.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  94 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   PIECES  .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7,0
  23. CLS
  24.  
  25. ? "┌─────────────────────────────────────────────────────────────────────────────
  26. ? "│ fGetPiece$  ( ANY, Sep?, PieceNo% )
  27. ? "│ fLastPiece$ ( ANY, Sep? )
  28. ? "│ fPiecePOS%  ( ANY, Sep?, PieceNo% )
  29. ? "│ fGetPieces$ (  V$, Sep?, First%, Last% )
  30. ? "│  SetPiece   (  V$, Sep?, PieceNo%, NewPiece$ )
  31. ? "├─────────────────────────────────────────────────────────────────────────────
  32. ? "│ These routines bring to PowerBASIC one of the most powerful functions of
  33. ? "│ the language MUMPS (M): the ability to parse a string into segments by using
  34. ? "│ a known separator (character). The concept is so innovative that it really
  35. ? "│ takes some time to get used to it but data is filled with natural separators
  36. ? "│ (eg: the spaces in this text) and they can be put to use in many, many ways
  37. ? "│ that allow your programs to flow smoother while providing greater power and
  38. ? "│ flexibility to your users. In the example, below, I use an address. As each
  39. ? "│ country has it's own idea of how long, how many lines, etc. their addresses
  40. ? "│ are, you either have to allow massive space to fit all address and waste a
  41. ? "│ lot of disk space storing chr$(32)s or put a max length on the data and let
  42. ? "│ the users determine how it is to be used.
  43. ? "└─────────────────────────────────────────────────────────────────────────────
  44.  
  45. Sep? = 124    ' "|"
  46. A1$  = "234 Main Street|Quincy, Il.|62301"
  47. A2$  = "482 High Queen's Road|Upper Londondary|Lower Essex|12W348-2"
  48.  
  49. FOR P% = 1 TO 4
  50.   PRINT fGetPiece$( A1$, Sep?, P% )
  51. NEXT
  52.  
  53. SetPiece A2$, Sep?, 2, "London-Darry"
  54.  
  55. FOR P% = 1 TO 4
  56.   LOCATE P% + 19, 40
  57.   PRINT fGetPiece$( A2$, Sep?, P% )
  58. NEXT
  59. LOCATE 25, 60 : PRINT "Thump a button...";
  60. fAnyKey
  61.  
  62. CLS
  63. ? "┌──────────────────────────────────────────────────────────────────────────────
  64. ? "│ Another good use for these functions (and we'll get deeper into this later)
  65. ? "│ is with names. Right now, in the USA, a FirstName Initial LastName is an
  66. ? "│ average of 17 characters. But which of those 17 characters are first/middle
  67. ? "│ and which are last? Well, most programs allow one long field for the name,
  68. ? "│ force the user to input a name in a particular format, and Katie bar the door
  69. ? "│ if it isn't correct! I've found it better to allow my users separate fields
  70. ? "│ for the last name, first/middle, and honorifics (Mr.,PhD. etc.) and restrict
  71. ? "│ them to a total length of the 3. This way Mr. Rob Robinowitzski, M.D.,PhD.
  72. ? "│ is allowed the same opportunity of having his full, correct name/title(s) as
  73. ? "│ Ms. Jane Doe and our users CAN'T MAKE A MISTAKE! (well.........:)
  74. ? "│ As I've said, I'll get back to all of this name stuff later but for now
  75. ? "│ just a quickie!
  76. ? "└──────────────────────────────────────────────────────────────────────────────
  77.  
  78. FullName$  = "Schullian|Donald A.|Mr.,Jr.,PhD.,MD,BS"
  79. LastName$  = fGetPiece$ ( FullName$ , 124, 1 )
  80. FirstName$ = fGetPiece$ ( FullName$ , 124, 2 )
  81. Honorific$ = fGetPiece$ ( FullName$ , 124, 3 )
  82. LHonors$   = fGetPiece$ ( Honorific$,  44, 1 )
  83. THonors$   = fGetPieces$( Honorific$,  44, 2, 0 ) ' all the rest
  84.  
  85. PRINT
  86. PRINT LHonors$; " "; FirstName$; " "; LastName$; ", "; THonors$
  87. PRINT
  88.  
  89. Dyte$ = DATE$
  90. Jdate$ = fGetPiece$ ( Dyte$, 45, 3 ) + "." +_
  91.          fGetPieces$( Dyte$, 45, 1, 2 )
  92. REPLACE "-" WITH "." IN Jdate$
  93. PRINT Jdate$
  94.